<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/css/common.css" />
<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/css/flatpickr.min.css" />
<link rel="stylesheet" type="text/css" href="/css/font-awesome.css" />
<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css" />

<script src="/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/dialog/js/dialog.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/jquery.form.js"></script>
<script src="/js/common.js"></script>
<script src="/js/flatpickr.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	<!--顶部导航 -->
		<nav class="topNavItemBox">
			<div id="ItemBox">
				<div class="title">肉品溯源管理系统</div>
			</div>
		</nav>
		<!-- 左侧导航 -->
	<#include "left.ftl"/>
    <div class="page_main">
		<h3>新增产品信息</h3><span class="add_link"><a href="slaughter.ftl">查看屠宰包装情况></a></span>
		<br />
		<div class="page_content">

			<form id="quarantine_addform" action="ProductAction_addProductInfo"
				method="post">
				<ul>
					<li><label class="labelBeforinput">*产品追溯码</label><input name="productInfo.traceCode"  class="bigInputtext" required data-rule-notZero="true" /></li>
					<li><label class="labelBeforinput">*生猪编号</label><input name="productInfo.purchaseInfo.gid" class="bigInputtext" required type="text"  data-rule-isIntGtZero="true" /></li>
					<li><label class="labelBeforinput">*生产企业</label><select name="productInfo.companyInfo.gid"  class="bigInputtext" required data-rule-notZero="true" >
							<option value="0">请选择</option>
							</select></li>
					<li><label class="labelBeforinput">*产品类型</label><select name="productInfo.producetypeLnfo2.gid"  class="bigInputtext" required data-rule-notZero="true">
							<option value="0">请选择</option>
							</select></li>
					<li><label class="labelBeforinput">*生产时间</label><input type="text" name="productInfo.processTime" class="bigInputtext" data-date-format="Y-m-d" required /></li>
					<li><label class="labelBeforinput">*生产人员编号</label><input name="productInfo.processerCode" type="text" class="bigInputtext" required data-rule-isIntGtZero="true"/></li>
					
					<li><label class="labelBeforinput">*检验结果类型</label><input type="text" name="purchaseInfo.inspectResultCode" class="bigInputtext" required data-rule-notOneortwo="true" /></li>
					<li><label class="labelBeforinput">*检验结果描述</label><input name="productInfo.inspectResult" type="text" class="bigInputtext" required /></li>
					<li><label class="labelBeforinput">*检验时间</label><input name="productInfo.inspectTime" type="text" class="bigInputtext" data-date-format="Y-m-d" required /></li>
					<li><label class="labelBeforinput">*检验台编号</label><input name="productInfo.inspecterCode" type="text" class="bigInputtext" required data-rule-isIntGtZero="true" /></li>
					
					<li><label class="labelBeforinput">销售商家编号</label><input name="productInfo.salerlD" type="text" class="bigInputtext" /></li>
					<li><label class="labelBeforinput">销售商家名称</label><input name="productInfo.salerName" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">销售终端编号</label><input name="productInfo.balancelD" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">销售终端编码</label><input name="productInfo.balanceCode" type="text" class="bigInputtext" /></li>
					
					<li><label class="labelBeforinput">产品单价</label><input name="productInfo.procPrice" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">产品单位</label><input name="productInfo.procUnit" type="text" class="bigInputtext" /></li>
					<li><label class="labelBeforinput">产品数量</label><input name="productInfo.procCount" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">产品计价</label><input name="productInfo.procAmount" type="text" class="bigInputtext" /></li>
					<li><label class="labelBeforinput">计价折扣</label><input name="productInfo.procDiscount" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">出售价格</label><input name="productInfo.sellPrice" type="text" class="bigInputtext"  /></li>
					<li><label class="labelBeforinput">出售日期</label><input name="productInfo.selledTime"  type="text" class="bigInputtext" data-date-format="Y-m-d"  /></li>

					<li><input type="submit" value="添加记录"
						style="margin-left: 170px; width: 200px;" /></li>
				</ul>
			</form>
		</div>
		<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
	</div>
</body>
<script>
	$(function() {
		//初始化侧边栏
		$(".vertical-nav").verticalnav({
			speed : 400,
			align : "left"
		});

		//时间控制器
		$("input[name='productInfo.processTime']").flatpickr();
		$("input[name='productInfo.inspectTime']").flatpickr();
		$("input[name='productInfo.selledTime']").flatpickr();
		
		
		
		//表单校验
		$("#quarantine_addform").validate();
		$.post("ProductAction_getcomp", function(data) {
				//$("select[nme='gid']").empty();
				console.log(data);
				for(var i = 0; i < data.length; i++) {
					$("select[name='productInfo.companyInfo.gid']").append("<option value='" + data[i].gid+ "'>" + data[i].compName+ "</option>");
					}
			});	
			
			$.post("ProductAction_getproType", function(data) {
				//$("select[name='gid']").empty();
				console.log(data);
				for(var i = 0; i < data.length; i++) {
					$("select[name='productInfo.producetypeLnfo2.gid']").append("<option value='" + data[i].gid+ "'>" + data[i].typeName + "</option>");
					}
			});	
		//表单提交
		$("#quarantine_addform")
				.ajaxForm(
						{
							/* error: function(XMLHttpRequest, textStatus, errorThrown){
								//失败
								$.dialog({
									type: 'info',
									contentHtml: '<img class="info-icon" src="dialog/images/icon/fail.png" alt="增加失败" /><p class="info-text">请输入正确的生猪编号</p>',
									autoClose: 2000
								});
							}, */
							success : function(data) {
								var str = null;
								var msg = null;
								if (data.msg==1) {
									str = "success";
									msg = "猪肉产品信息录入成功";
								} else {
									str = "fail";
									msg = data.msg;
								}
								console.log(data);
								$.dialog({
									type : 'info',
									contentHtml : '<img class="info-icon" src="dialog/images/icon/'+str+'.png" alt="'+msg+'" /><p class="info-text">'
											+ msg + '</p>',
								 autoClose:2000
								});
							}
						});
	});
</script>

</html>